package edu.tapestry.iddb.client.pages;

import iddb.AbstractResponse;
import iddb.OkResponse;

import org.apache.tapestry5.annotations.ApplicationState;
import org.apache.tapestry5.annotations.InjectPage;

import edu.tapestry.iddb.client.webService.CommandsGenerator;
import edu.tapestry.iddb.client.webService.IDDBProxy;

public class Connect {

	@ApplicationState
	private IDDBProxy proxy;

	@InjectPage
	private OKPage ok;
	
	@InjectPage
	private ErrorPage error;

	Object onActionFromCreate() {

		AbstractResponse resp = proxy.execute(CommandsGenerator
				.createConnectCommand());

		if (resp instanceof OkResponse){
			return ok.initialize(resp);
		}
		else {
			return error.initialize(resp);
		}
	}
}
